package com.wise.service.cms.content.applicationcolumn;

import cn.hutool.core.bean.BeanUtil;
import com.wise.entities.content.ApplicationColumn;
import com.wise.framework.basic.DateTimeUtil;
import com.wise.framework.daomodel.DaoSave;
import com.wise.framework.session.CurrentUserId;
import com.wise.framework.session.GetAcceptLanguage;
import com.wise.summer.v1.cms.content.applicationcolumn.AddApplicationColumn;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

/**
 * @author hejiawei
 * @date 2020/10/27 11:08
 */
@Service
@SummerService
public class AddApplicationColumnService implements SummerServiceBean<AddApplicationColumn> {
    @Override
    public void sum(AddApplicationColumn model) {
        String lang = GetAcceptLanguage.s(true);
        ApplicationColumn applicationColumn = new ApplicationColumn();
        BeanUtil.copyProperties(model, applicationColumn);
        applicationColumn.setLang(lang);
        applicationColumn.setAlias(model.getAlias());
        applicationColumn.setCreatedBy(CurrentUserId.s(true));
        applicationColumn.setCreationDate(DateTimeUtil.timestampNow());
        DaoSave.s(applicationColumn);
        model.setSummerResult(applicationColumn);
    }
}
